نمونه ها و دموها
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
همه نمونههای موجود در مجموعه مستندات Embedded Viewer API برای ارجاع سریع در زیر فهرست شدهاند. علاوه بر این، تعدادی دمو اضافی برای نشان دادن مفاهیم پیشرفته گنجانده شده است.
نمونه هایی از راهنمای برنامه نویس
این مثالهای اولیه در راهنمای توسعهدهنده ظاهر میشوند و رایجترین کاربردهای Embedded Viewer API را پوشش میدهند.
- کتاب ساده
مثال "Hello, World" از Embedded Viewer API، این مثال نحوه بارگیری API و ترسیم بیننده با یک کتاب خاص را نشان می دهد. - زبان کتاب
این مثال نحوه تغییر زبان رابط بیننده، در این مورد به پرتغالی برزیل را نشان می دهد. - کتاب یافت نشد
این نشان می دهد که چگونه می توان یک تابع تماس را اضافه کرد که زمانی فراخوانی می شود که بیننده نتواند کتاب مشخص شده را بارگیری کند. شما می توانید از این مثال استفاده کنید تا به خوبی چنین شرایطی را مدیریت کنید. - کتاب-موفقیت
این نشان میدهد که چگونه میتوان یک تابع تماس را اضافه کرد که زمانی فراخوانی میشود که بیننده با موفقیت یک کتاب را مقداردهی اولیه کند و آماده دستکاری برنامهای باشد. - کتاب - جاندار
برای نشان دادن اینکه چگونه میتوان بیننده را با استفاده از جاوا اسکریپت به صورت برنامهنویسی کنترل کرد، یک پیشنمایش نشان داده میشود که هر 3 ثانیه بهطور خودکار به صفحه بعدی باز میگردد.
کنترل برنامه ای بیننده
بیننده به شما امکان می دهد تقریباً هر کاری را که کاربر می تواند با تعامل با بیننده انجام دهد، با کد انجام دهید. مثالهای زیر نشان میدهند که چگونه این ممکن است مفید باشد.
- کتاب-تعامل-کنترل
این مثال کاری تمام روشهای تعاملی را که توسط بیننده پشتیبانی میشود، از جمله زوم، nextPage، goToPage و توابع برجسته کردن را برمیشمارد. - کتاب-تعامل-صفحه باز
نحوه باز کردن خودکار نمایشگر کتاب در یک صفحه خاص را با استفاده از تماسهای برگشتی و عملکرد goToPage نشان میدهد.
ترکیب با Books API و Dynamic Links
هنگام ساخت برنامه های پیشرفته، ممکن است ترکیب API نمایشگر جاسازی شده با ویژگی Books API یا Dynamic Links مفید باشد. به عنوان مثال، ممکن است از قبل دانستن اینکه آیا یک پیشنمایش خاص برای جاسازی در دسترس است یا خیر مفید باشد (مثلاً برای تعیین اینکه آیا به کاربر این امکان را میدهد که یک پنجره پیشنمایش در سایت شما باز کند یا خیر). یا ممکن است شناسه یک کتاب خاص را ندانید و بخواهید ابتدا با استفاده از Books API آن را جستجو کنید. مثال های زیر نحوه انجام این عملیات را نشان می دهد.
- book-dynamiclinks-zippy
در اینجا ابتدا بررسی می کنیم که آیا کتابی برای جاسازی در دسترس است یا خیر. اگر و فقط در صورت موجود باشد، یک "پیش نمایش فشرده" ارائه می کنیم، که با کلیک کردن، پیش نمایش کتاب را به صورت خطی نشان می دهد. - booksapi-titlesearch
این مثال به شما امکان میدهد تا با وارد کردن یک عبارت جستجو برای یک کتاب، یک نمایشگر تعبیهشده را باز کنید. به طور خودکار اولین نتیجه قابل جاسازی را برای درخواستی که وارد می کنید نشان می دهد. این از فرمت خروجی JSON Data API برای دسترسی به نتایج جستجو استفاده می کند.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2024-10-30 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2024-10-30 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eThis documentation provides a comprehensive list of examples for Google Books Embedded Viewer API.\u003c/p\u003e\n"],["\u003cp\u003eExamples cover basic viewer setup, language settings, error handling, and programmatic control functionalities.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can learn to integrate the viewer with the Books API and Dynamic Links for advanced functionalities.\u003c/p\u003e\n"],["\u003cp\u003eSample code demonstrates interactions like zooming, navigation, and highlighting within the embedded viewer.\u003c/p\u003e\n"],["\u003cp\u003eUse cases include creating book previews, searching for books, and handling embedding availability.\u003c/p\u003e\n"]]],[],null,["# Examples and Demos\n\nAll of the examples contained within the Embedded Viewer API documentation set are listed below for quick reference. In addition, a number of additional demos are included to illustrate advanced concepts.\n\nExamples from the Developer's Guide\n-----------------------------------\n\nThese basic examples appear in the [Developer's Guide](/books/docs/viewer/developers_guide) and cover the most common uses of the Embedded Viewer API.\n\n- [book-simple](/books/docs/viewer/examples/book-simple) \n The \"Hello, World\" example of the Embedded Viewer API, this example indicates how to load the API and draw a viewer with a particular book.\n- [book-language](/books/docs/viewer/examples/book-language) \n This example shows how to change the viewer's interface language, in this case to Brazilian Portuguese.\n- [book-notfound](/books/docs/viewer/examples/book-notfound) \n This shows how to add a callback function which is called when the viewer could not load the specified book. You can build on this example to gracefully handle such conditions.\n- [book-success](/books/docs/viewer/examples/book-success) \n This shows how to add a callback function which is called when the viewer has successfully initialized with a book and is ready to be manipulated programatically.\n- [book-animate](/books/docs/viewer/examples/book-animate) \n To illustrate how the viewer can be controlled programmatically using JavaScript, a preview is shown which automatically flips to the next page every 3 seconds.\n\nProgrammatic control of the viewer\n----------------------------------\n\nThe viewer allows you to do with code almost anything the user can do by interacting with the the viewer. The examples below show how this might be useful.\n\n- [book-interactions-controls](/books/docs/viewer/examples/book-interactions-controls) \n This working example enumerates all the interaction methods supported by the viewer, including zoom, nextPage, goToPage, and highlighting functions.\n- [book-interactions-openatpage](/books/docs/viewer/examples/book-interactions-openatpage) \n Shows how to automatically open a book viewer on a particular page, using callbacks and the goToPage function.\n\nCombining with the Books API and Dynamic Links\n----------------------------------------------\n\nWhen building advanced applications, you may find it useful to combine\nthe Embedded Viewer API with either the [Books API](/books/docs/v1/getting_started) or the\n[Dynamic Links](/books/docs/dynamic-links)\nfeature. For example, it may be useful to know in advance whether a particular\npreview will be available for embedding (e.g., to determine whether to give the\nuser the option to open a preview window on your site). Or, you may not know the\nidentifier for a particular book, and want to first \"look it up\" using the Books\nAPI. The examples below indicate how to perform these operations.\n\n- [book-dynamiclinks-zippy](/books/docs/viewer/examples/book-dynamiclinks-zippy) \n Here we check whether a book is available for embedding first. If and only if it is available, we render a \"preview zippy,\" which, when clicked, shows the book preview inline.\n- [booksapi-titlesearch](/books/docs/viewer/examples/booksapi-titlesearch) \n This example allows you open an embedded viewer by simply entering a search query for a book. It will automatically show the first embeddable result for the query you enter. This uses the JSON output format of the Data API to access the search results."]]